using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace PantheonSoftware.InfoCollection
{
    /// <summary>
    /// Interface which allows concurrent transactions across database connections
    /// </summary>
    public interface IDbManager
    {
        /// <summary>
        /// Begins the transaction. The transaction is pending until either Commit or Rollback is called
        /// </summary>
        void BeginTransaction();
        /// <summary>
        /// Commits the transaction and closes the connection
        /// </summary>
        void Commit();
        /// <summary>
        /// Rollbacks this transaction and closes the connection
        /// </summary>
        void Rollback();
        /// <summary>
        /// Updates the data source with the data in the supplied DataSet.
        /// This is the proxy update function. 
        /// </summary>
        /// <param name="ds">The DataSet to update.</param>
        /// <param name="updateDelegate">The true Update function to call.</param>
        /// <returns>The updated DataSet</returns>
        DataSet Update(DataSet ds, UpdateHandler updateDelegate);
        /// <summary>
        /// Returns the internal connection object.
        /// </summary>
        /// <value>The connection.</value>
        SqlConnection Connection { get; }
        /// <summary>
        /// Returns the internal transaction object.
        /// </summary>
        /// <value>The transaction.</value>
        SqlTransaction Transaction { get; }
    }
}
